/* Polynom.h header file
   ---------------------
   Specifies Polynom class properties and methods
 */

#ifndef _POLYNOM_H
#define _POLYNOM_H

#include <iostream>
#include "Monom.h"
#include "DL_List.h"

using namespace std;


class Polynom {

	// friends & overloading
	friend ostream& operator<<(ostream& out, const Polynom &p) {	// cout operator << for Polynom
		out << p.poly;
		return out;
	};
    friend Polynom operator+(const Polynom &p1, const Polynom &p2); // Polynom/Monom + Polynom/Monom
    friend Polynom operator-(const Polynom &p1, const Polynom &p2); // Polynom/Monom - Polynom/Monom

public:
	
	// Constructors & stuff
	Polynom::Polynom() {						// Default Polynom Constructor
		// Insert Default Monom 0
		poly.PushFront(Monom());
	};
	Polynom::Polynom(const Monom &m) {			// Constructor Monom to Polynom
		this->poly.PushFront(m);
	};
	Polynom::~Polynom() {						// Destructor
		// Free all allocated DL_Nodes
		poly.Clear();
	};
	Polynom::Polynom(const Polynom &p);			// Copy Constructor - Polynom

	// Operators
	const Polynom& operator=(const Polynom &p);	// Assignment operator

	// Methods
	const int getOrder() const { return (poly.Back())->getExponent(); };	// Return's Polynom order
	const Polynom& derive();												// Derives Polynom & returns reference to *this

private:
    DL_List<Monom> poly;		// Polynom head
	void allMinus();			// Applies multiply with (-1) for all Monoms' 
								// coefficients in Polynom
};

#endif